-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Exclude cache files from rules compilation #5283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
## Summary
Prevents system files like `.DS_Store`, `.Thumbs.db`, and other cache files from being processed as rule files in the `.roo/rules-{mode-slug}` directories.
## Changes
- Added `shouldIncludeRuleFile()` function to filter out unwanted files during rule compilation
- Modified `readTextFilesFromDirectory()` to apply file filtering before processing
- Added support for 21 common cache file patterns including `.DS_Store`, `.db`, `.bak`, `.log`, etc.
- Updated comment to reflect the new filtering behavior
## Impact
- Fixes issue where macOS `.DS_Store` files were being included in system prompts
- Prevents other cache and temporary files from polluting rule compilation
- Improves system prompt quality and reduces noise
## Additional Notes
**Why we didn't import from existing exclusion patterns:**
The existing `getCacheFilePatterns()` function in `src/services/checkpoints/excludes.ts` contains identical patterns, but we cannot import from it due to architectural constraints:
- The `custom-instructions.ts` file is imported by webview components that run in the browser
- `excludes.ts` has Node.js dependencies (`fs/promises`, `path`) that cannot be bundled for browser environments
- Importing from `excludes.ts` would cause Vite build failures in the webview
This is a necessary architectural trade-off to maintain browser compatibility while solving the cache file inclusion issue.
Resolves: RooCodeInc#2728
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
…tion ## Summary Addresses feedback by adding comprehensive test coverage for cache file filtering and simplifying the filtering logic using functional programming patterns. ## Changes - **Test Coverage**: Added `"should filter out cache files from .roo/rules/ directory"` test case - Tests filtering of `.DS_Store`, `Thumbs.db`, `.bak`, `.log`, `.tmp`, `.pyc` files - Verifies rule files are still processed correctly - Confirms cache files are completely excluded from processing - Prevents future regressions in filtering logic - **Code Simplification**: Refactored `shouldIncludeRuleFile()` function - Replaced for loop with `.some()` method for more concise logic - Improved functional programming style while maintaining identical behavior - Enhanced code readability and maintainability ## Impact - ✅ 25/27 tests passing with comprehensive cache file filtering coverage - ✅ More maintainable and testable codebase - ✅ Prevents future regressions in rule compilation filtering - ✅ Addresses all reviewer feedback points ## Technical Notes - Test uses mock file system to simulate various cache file types - Verifies that `readFileMock` is never called for filtered cache files - Maintains cross-platform compatibility (Windows/Unix path handling)
|
Thank you @MuriloFP I updated the implementation to use an allowlist approach instead of maintaining a blocklist of files to exclude. Now it only accepts known rule file extensions: This is cleaner and more predictable. We define exactly what we want, rather than trying to try and guess everything we don't. It also solves the original The tests have been updated to reflect this change, and all CI checks are passing. |
eea2620 to
cbf0c99
Compare
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrubens
I reverted the changes
LGTM
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Related GitHub Issue
Closes: #2728
Description
Summary
Prevents system files like
.DS_Store,.Thumbs.db, and other cache files from being processed as rule files in the.roo/rules-{mode-slug}directories.Changes
shouldIncludeRuleFile()function to filter out unwanted files during rule compilationreadTextFilesFromDirectory()to apply file filtering before processing.DS_Store,.db,.bak,.log, etc.Impact
.DS_Storefiles were being included in system promptsTest Procedure
Manual Testing
On the current main branch, we see the content from the .DS_Store and other files being added, there's no filter.
With this implementation, the files are filtered and not included in the rules.
"should filter out cache files from .roo/rules/ directory"test case.DS_Store,Thumbs.db,.bak,.log,.tmp,.pycfilesPre-Submission Checklist
Screenshots / Videos
Documentation Updates
Additional Notes
Why we didn't import from existing exclusion patterns:
The existing
getCacheFilePatterns()function insrc/services/checkpoints/excludes.tscontains identical patterns, but we cannot import from it due to architectural constraints:custom-instructions.tsfile is imported by webview components that run in the browserexcludes.tshas Node.js dependencies (fs/promises,path) that cannot be bundled for browser environmentsexcludes.tswould cause Vite build failures in the webviewThis is a necessary architectural trade-off to maintain browser compatibility while solving the cache file inclusion issue.
Let me know if any other changes are needed, or if I should add tests for the filtering logic.
Get in Touch
@MuriloFP
Important
Adds
shouldIncludeRuleFile()to filter out cache files from rule compilation incustom-instructions.ts, improving prompt quality.shouldIncludeRuleFile()incustom-instructions.tsto exclude cache files like.DS_Store,.Thumbs.db, etc., from rule compilation.readTextFilesFromDirectory()to useshouldIncludeRuleFile()for filtering files before processing..DS_Storefiles being included in system prompts.This description was created by
for ec62e2f. You can customize this summary. It will automatically update as commits are pushed.